﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using RimWorld.Planet;
using Verse;

namespace Miao.Stand
{
    public class StandData : IExposable
    {
        public bool ActiveStand;

        public void ExposeData()
        {
            Scribe_Values.Look(ref ActiveStand, "MiaoActive");
            //Scribe_Deep.Look(ref Active, "MiaoActive");

            // Scribe_References.Look<bool>(ref Active,"active");
        }
    }

    //RimWorld 将自动创建从 Map-、World- 或 GameComponent 继承的所有类的实例。
    /// <summary>
    /// 替身缓存类
    /// </summary>
    public class StandWorldSave : WorldComponent//应该存在世界里
    {
        public static StandWorldSave Instance;

        public Dictionary<string, StandData> standSave = new Dictionary<string, StandData>();
        public StandWorldSave(World world) : base(world)
        {
            if (Instance != null)
            {
                Log.Warning("已经存在该单例");
            }
            Instance = this;

        }
        public StandData Get(string key)
        {
            StandData standData;
            if (standSave.TryGetValue(key, out standData))
            {
                return standData;
            }
            else
            {
                standData = new StandData();
                standSave.Add(key, standData);
                return standData;
            }
        }
        public override void ExposeData()
        {
            Scribe_Collections.Look<string, StandData>(ref standSave, "Stand", LookMode.Value, LookMode.Deep);//读取模式需要定义一下
            base.ExposeData();
        }
    }
}
